package cn.jilian.entity;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.jilian.entity.AbstractEntity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;

@Entity
@Table(name="bt_user")
@DiscriminatorColumn(name="meta",discriminatorType=DiscriminatorType.INTEGER)
public class User extends AbstractEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8460974270277975438L;

	/**
	 * 司机
	 * */ 
	public static final String DRIVER_META="539590";

	/**
	 * 物流公司管理员用户
	 * */ 
	public static final String TRANS_ADMIN_META="539607";

	/**
	 * 厂家代理商管理员用户
	 * */ 
	public static final String SUPPLIER_ADMIN_META="539608";

	/**
	 * 平台系统管理员用户
	 * */ 
	public static final String SYS_ADMIN_META="539609";


	public User() {
		
	}
	/**
	 * 用户名
	 * */ 
	@Column(name="NAME",unique=true)
	private String username;

	
	/**
	 * 工号
	 * */ 
	@Column(name="CODE")
	private String jobCode;

	
	/**
	 * 姓名
	 * */ 
	@Column(name="surname")
	private String surname;

	
	/**
	 * 全称
	 * */ 
	@Column(name="fullname")
	private String fullname;

	
	/**
	 * 手机号
	 * */ 
	@Column(name="mobile")
	private String mobile;

	
	/**
	 * 即时通讯
	 * */ 
	@Column(name="imcode")
	private String imcode;
	
	@Column(name="birth")
	@Temporal(TemporalType.DATE)
	private Date birth;
	
	@Column(name="gender")
	private Integer gender;
	
	@Column(name="unid")
	private Long unitId;
	
	@Column(name="flag")
	private Integer flag=1;
	
	@Column(name="rank")
	private Integer rank=210609;
	
	@Column(name="mark")
	private String mark;
	
	@Column(name="email")
	private String email;
	
	
	
	@ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinTable(name="bt_link",joinColumns= {@JoinColumn(name="source",referencedColumnName="sid",foreignKey =@ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))},
	inverseJoinColumns= {@JoinColumn(name="relate",referencedColumnName="sid",foreignKey =@ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))})
	private Set<Role> roles;

	

	public String getUsername(){
		return this.username;
	}

	public void setUsername(String username){
		this.username=username;
	}

	public String getJobCode(){
		return this.jobCode;
	}

	public void setJobCode(String jobCode){
		this.jobCode=jobCode;
	}

	public String getSurname(){
		return this.surname;
	}

	public void setSurname(String surname){
		this.surname=surname;
	}

	public String getFullname(){
		return this.fullname;
	}

	public void setFullname(String fullname){
		this.fullname=fullname;
	}

	public String getMobile(){
		return this.mobile;
	}

	public void setMobile(String mobile){
		this.mobile=mobile;
	}

	public String getImcode(){
		return this.imcode;
	}

	public void setImcode(String imcode){
		this.imcode=imcode;
	}


	public Integer getFlag() {
		return flag;
	}

	public void setFlag(Integer flag) {
		this.flag = flag;
	}

	public Integer getRank() {
		return rank;
	}

	public void setRank(Integer rank) {
		this.rank = rank;
	}

	public Long getUnitId() {
		return unitId;
	}

	public void setUnitId(Long unitId) {
		this.unitId = unitId;
	}


	public Date getBirth() {
		return birth;
	}

	public void setBirth(Date birth) {
		this.birth = birth;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public String getMark() {
		return mark;
	}

	public void setMark(String mark) {
		this.mark = mark;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	
}